//
//  LoadingView.m
//  PaiLeXiongProject
//
//  Created by 小獾科技 on 2017/9/26.
//  Copyright © 2017年 小獾科技. All rights reserved.
//

#import "LoadingView.h"

@implementation LoadingView


- (instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame])
    {
        self.backgroundColor = ColorWhite;
        [self setReminderLabelTitle:nil andImage:nil];
    }
    return self;
}


- (void)setReminderLabelTitle:(NSString *)reminderString andImage:(NSString *)imageName
{
    _imageView = [UIImageView new];
    _imageView.image = IMAGE(STRING(imageName));
    [self addSubview:_imageView];
    [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.centerY.equalTo(self.mas_centerY).offset(-40);
        make.width.equalTo(@130);
        make.height.equalTo(@130);
    }];
    
    _reminderLabel = [UILabel new];
    _reminderLabel.textColor = ColorFrom16(0xF5CB37);
    _reminderLabel.font = PFMFONT(14);
    _reminderLabel.text = reminderString;
    _reminderLabel.textAlignment = 1;
    [self addSubview:_reminderLabel];
    [_reminderLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_imageView.mas_bottom).offset(15);
        make.centerX.equalTo(self.mas_centerX);
        make.width.greaterThanOrEqualTo(@80);
        make.height.equalTo(@20);
    }];
    
    _refreshBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_refreshBtn setTitle:@"刷新试试~" forState:0];
    [_refreshBtn setTitleColor:ColorFrom16(0xFEDE6D) forState:0];
    _refreshBtn.layer.borderColor = ColorFrom16(0xFEDE6D).CGColor;
    _refreshBtn.layer.borderWidth = 1;
    _refreshBtn.layer.cornerRadius = 20;
    _refreshBtn.layer.masksToBounds = YES;
    _refreshBtn.hidden = YES;
    _refreshBtn.titleLabel.font = PFRFONT(16);
    [self addSubview:_refreshBtn];
    [_refreshBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_reminderLabel.mas_bottom).offset(10);
        make.centerX.equalTo(self.mas_centerX);
        make.width.equalTo(@136);
        make.height.equalTo(@40);
    }];
}


@end
